home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / cblas / test_spmv.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-04-18  |  8.5 KB  |  364 lines

  1. #include <gsl/gsl_test.h>
  2. #include <gsl/gsl_ieee_utils.h>
  3. #include <gsl/gsl_math.h>
  4. #include <gsl/gsl_cblas.h>
  5.  
  6. #include "tests.h"
  7.  
  8. void
  9. test_spmv (void) {
  10. const double flteps = 1e-4, dbleps = 1e-6;
  11.   {
  12.    int order = 101;
  13.    int uplo = 121;
  14.    float alpha = 0.1f;
  15.    float beta = -0.3f;
  16.    int N = 2;
  17.    float A[] = { -0.174f, 0.878f, 0.478f };
  18.    float X[] = { 0.503f, 0.313f };
  19.    int incX = -1;
  20.    float Y[] = { -0.565f, -0.109f };
  21.    int incY = -1;
  22.    float y_expected[] = { 0.221025f, 0.0714172f };
  23.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  24.    {
  25.      int i;
  26.      for (i = 0; i < 2; i++) {
  27.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1134)");
  28.      }
  29.    };
  30.   };
  31.  
  32.  
  33.   {
  34.    int order = 101;
  35.    int uplo = 121;
  36.    float alpha = 0.1f;
  37.    float beta = -0.3f;
  38.    int N = 2;
  39.    float A[] = { -0.174f, 0.878f, 0.478f };
  40.    float X[] = { 0.503f, 0.313f };
  41.    int incX = -1;
  42.    float Y[] = { -0.565f, -0.109f };
  43.    int incY = -1;
  44.    float y_expected[] = { 0.221025f, 0.0714172f };
  45.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  46.    {
  47.      int i;
  48.      for (i = 0; i < 2; i++) {
  49.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1135)");
  50.      }
  51.    };
  52.   };
  53.  
  54.  
  55.   {
  56.    int order = 101;
  57.    int uplo = 122;
  58.    float alpha = 0.1f;
  59.    float beta = -0.3f;
  60.    int N = 2;
  61.    float A[] = { -0.174f, 0.878f, 0.478f };
  62.    float X[] = { 0.503f, 0.313f };
  63.    int incX = -1;
  64.    float Y[] = { -0.565f, -0.109f };
  65.    int incY = -1;
  66.    float y_expected[] = { 0.221025f, 0.0714172f };
  67.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  68.    {
  69.      int i;
  70.      for (i = 0; i < 2; i++) {
  71.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1136)");
  72.      }
  73.    };
  74.   };
  75.  
  76.  
  77.   {
  78.    int order = 101;
  79.    int uplo = 122;
  80.    float alpha = 0.1f;
  81.    float beta = -0.3f;
  82.    int N = 2;
  83.    float A[] = { -0.174f, 0.878f, 0.478f };
  84.    float X[] = { 0.503f, 0.313f };
  85.    int incX = -1;
  86.    float Y[] = { -0.565f, -0.109f };
  87.    int incY = -1;
  88.    float y_expected[] = { 0.221025f, 0.0714172f };
  89.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  90.    {
  91.      int i;
  92.      for (i = 0; i < 2; i++) {
  93.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1137)");
  94.      }
  95.    };
  96.   };
  97.  
  98.  
  99.   {
  100.    int order = 102;
  101.    int uplo = 121;
  102.    float alpha = 0.1f;
  103.    float beta = -0.3f;
  104.    int N = 2;
  105.    float A[] = { -0.174f, 0.878f, 0.478f };
  106.    float X[] = { 0.503f, 0.313f };
  107.    int incX = -1;
  108.    float Y[] = { -0.565f, -0.109f };
  109.    int incY = -1;
  110.    float y_expected[] = { 0.221025f, 0.0714172f };
  111.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  112.    {
  113.      int i;
  114.      for (i = 0; i < 2; i++) {
  115.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1138)");
  116.      }
  117.    };
  118.   };
  119.  
  120.  
  121.   {
  122.    int order = 102;
  123.    int uplo = 121;
  124.    float alpha = 0.1f;
  125.    float beta = -0.3f;
  126.    int N = 2;
  127.    float A[] = { -0.174f, 0.878f, 0.478f };
  128.    float X[] = { 0.503f, 0.313f };
  129.    int incX = -1;
  130.    float Y[] = { -0.565f, -0.109f };
  131.    int incY = -1;
  132.    float y_expected[] = { 0.221025f, 0.0714172f };
  133.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  134.    {
  135.      int i;
  136.      for (i = 0; i < 2; i++) {
  137.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1139)");
  138.      }
  139.    };
  140.   };
  141.  
  142.  
  143.   {
  144.    int order = 102;
  145.    int uplo = 122;
  146.    float alpha = 0.1f;
  147.    float beta = -0.3f;
  148.    int N = 2;
  149.    float A[] = { -0.174f, 0.878f, 0.478f };
  150.    float X[] = { 0.503f, 0.313f };
  151.    int incX = -1;
  152.    float Y[] = { -0.565f, -0.109f };
  153.    int incY = -1;
  154.    float y_expected[] = { 0.221025f, 0.0714172f };
  155.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  156.    {
  157.      int i;
  158.      for (i = 0; i < 2; i++) {
  159.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1140)");
  160.      }
  161.    };
  162.   };
  163.  
  164.  
  165.   {
  166.    int order = 102;
  167.    int uplo = 122;
  168.    float alpha = 0.1f;
  169.    float beta = -0.3f;
  170.    int N = 2;
  171.    float A[] = { -0.174f, 0.878f, 0.478f };
  172.    float X[] = { 0.503f, 0.313f };
  173.    int incX = -1;
  174.    float Y[] = { -0.565f, -0.109f };
  175.    int incY = -1;
  176.    float y_expected[] = { 0.221025f, 0.0714172f };
  177.    cblas_sspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  178.    {
  179.      int i;
  180.      for (i = 0; i < 2; i++) {
  181.        gsl_test_rel(Y[i], y_expected[i], flteps, "sspmv(case 1141)");
  182.      }
  183.    };
  184.   };
  185.  
  186.  
  187.   {
  188.    int order = 101;
  189.    int uplo = 121;
  190.    double alpha = -1;
  191.    double beta = 0.1;
  192.    int N = 2;
  193.    double A[] = { -0.181, -0.071, -0.038 };
  194.    double X[] = { -0.015, 0.132 };
  195.    int incX = -1;
  196.    double Y[] = { -0.449, -0.219 };
  197.    int incY = -1;
  198.    double y_expected[] = { -0.036098, 9.27e-04 };
  199.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  200.    {
  201.      int i;
  202.      for (i = 0; i < 2; i++) {
  203.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1142)");
  204.      }
  205.    };
  206.   };
  207.  
  208.  
  209.   {
  210.    int order = 101;
  211.    int uplo = 121;
  212.    double alpha = -1;
  213.    double beta = 0.1;
  214.    int N = 2;
  215.    double A[] = { -0.181, -0.071, -0.038 };
  216.    double X[] = { -0.015, 0.132 };
  217.    int incX = -1;
  218.    double Y[] = { -0.449, -0.219 };
  219.    int incY = -1;
  220.    double y_expected[] = { -0.036098, 9.27e-04 };
  221.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  222.    {
  223.      int i;
  224.      for (i = 0; i < 2; i++) {
  225.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1143)");
  226.      }
  227.    };
  228.   };
  229.  
  230.  
  231.   {
  232.    int order = 101;
  233.    int uplo = 122;
  234.    double alpha = -1;
  235.    double beta = 0.1;
  236.    int N = 2;
  237.    double A[] = { -0.181, -0.071, -0.038 };
  238.    double X[] = { -0.015, 0.132 };
  239.    int incX = -1;
  240.    double Y[] = { -0.449, -0.219 };
  241.    int incY = -1;
  242.    double y_expected[] = { -0.036098, 9.27e-04 };
  243.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  244.    {
  245.      int i;
  246.      for (i = 0; i < 2; i++) {
  247.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1144)");
  248.      }
  249.    };
  250.   };
  251.  
  252.  
  253.   {
  254.    int order = 101;
  255.    int uplo = 122;
  256.    double alpha = -1;
  257.    double beta = 0.1;
  258.    int N = 2;
  259.    double A[] = { -0.181, -0.071, -0.038 };
  260.    double X[] = { -0.015, 0.132 };
  261.    int incX = -1;
  262.    double Y[] = { -0.449, -0.219 };
  263.    int incY = -1;
  264.    double y_expected[] = { -0.036098, 9.27e-04 };
  265.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  266.    {
  267.      int i;
  268.      for (i = 0; i < 2; i++) {
  269.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1145)");
  270.      }
  271.    };
  272.   };
  273.  
  274.  
  275.   {
  276.    int order = 102;
  277.    int uplo = 121;
  278.    double alpha = -1;
  279.    double beta = 0.1;
  280.    int N = 2;
  281.    double A[] = { -0.181, -0.071, -0.038 };
  282.    double X[] = { -0.015, 0.132 };
  283.    int incX = -1;
  284.    double Y[] = { -0.449, -0.219 };
  285.    int incY = -1;
  286.    double y_expected[] = { -0.036098, 9.27e-04 };
  287.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  288.    {
  289.      int i;
  290.      for (i = 0; i < 2; i++) {
  291.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1146)");
  292.      }
  293.    };
  294.   };
  295.  
  296.  
  297.   {
  298.    int order = 102;
  299.    int uplo = 121;
  300.    double alpha = -1;
  301.    double beta = 0.1;
  302.    int N = 2;
  303.    double A[] = { -0.181, -0.071, -0.038 };
  304.    double X[] = { -0.015, 0.132 };
  305.    int incX = -1;
  306.    double Y[] = { -0.449, -0.219 };
  307.    int incY = -1;
  308.    double y_expected[] = { -0.036098, 9.27e-04 };
  309.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  310.    {
  311.      int i;
  312.      for (i = 0; i < 2; i++) {
  313.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1147)");
  314.      }
  315.    };
  316.   };
  317.  
  318.  
  319.   {
  320.    int order = 102;
  321.    int uplo = 122;
  322.    double alpha = -1;
  323.    double beta = 0.1;
  324.    int N = 2;
  325.    double A[] = { -0.181, -0.071, -0.038 };
  326.    double X[] = { -0.015, 0.132 };
  327.    int incX = -1;
  328.    double Y[] = { -0.449, -0.219 };
  329.    int incY = -1;
  330.    double y_expected[] = { -0.036098, 9.27e-04 };
  331.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  332.    {
  333.      int i;
  334.      for (i = 0; i < 2; i++) {
  335.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1148)");
  336.      }
  337.    };
  338.   };
  339.  
  340.  
  341.   {
  342.    int order = 102;
  343.    int uplo = 122;
  344.    double alpha = -1;
  345.    double beta = 0.1;
  346.    int N = 2;
  347.    double A[] = { -0.181, -0.071, -0.038 };
  348.    double X[] = { -0.015, 0.132 };
  349.    int incX = -1;
  350.    double Y[] = { -0.449, -0.219 };
  351.    int incY = -1;
  352.    double y_expected[] = { -0.036098, 9.27e-04 };
  353.    cblas_dspmv(order, uplo, N, alpha, A, X, incX, beta, Y, incY);
  354.    {
  355.      int i;
  356.      for (i = 0; i < 2; i++) {
  357.        gsl_test_rel(Y[i], y_expected[i], dbleps, "dspmv(case 1149)");
  358.      }
  359.    };
  360.   };
  361.  
  362.  
  363. }
  364.